package com.xufeng.demo.Controller;

import cn.hutool.core.date.DateUtil;
import cn.springmix.base.lang.entity.R;
import cn.springmix.core.exception.ServiceException;
import dto.HelloVo;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import test.feign.HelloFeignService;

import java.util.concurrent.Callable;

/**
 * @author xufeng
 * @description: 测试一下包装类 和全局异常
 * @date 2022-04-20 13:47
 */
@Slf4j
@RestController
public class TestController implements HelloFeignService {



    @Override
    public R<HelloVo> hello() {
        log.info("访问了hello");
        return R.OK(new HelloVo("hello", DateUtil.now()));
    }

    @GetMapping("/serviceEx")
    public void serviceEx(){
        throw new ServiceException(200,"zzz");
    }

    /**
     * 测试异步回调。减少主线程等待 提高并发
     * @return
     */
    @SneakyThrows
    @GetMapping(value = "index")
    public Callable<R> GetMonthCdateRpt() {
        return () -> R.OK("success1");
    }


}
